# 元组--不可修改
# 元组的定义
t1 = (1, "hello", '123', True)
t2 = ()
t3 = tuple('1',)
print(type(t3))

# 定义单个元素的元组
t4 = ("hello",)  # 要加上单独的,

# 嵌套
t5 = (1, 2, 3, (1, 2))
print(t5[3][0])

# index
t6 = ('heima', '1', 2, 3, '1', '1')
print(t6.index('1'))

# count
print(t6.count('1'))

# len
print(len(t6))

# 元组遍历
print("######################")
index = 0
while index < len(t6):
    print(t6[index])
    index += 1


for element in t6:
    print(element)

#元组内嵌套list,此时可以修改list中的元素
t7 = (1,2,3,[4,5,6])
t7[3][1] = 7
print(t7)